package com.ss.android.k.c;

import android.app.Activity;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;

import com.ss.android.k.d.a;
import com.ss.android.k.dd;

import java.util.LinkedList;
import java.util.Queue;

public abstract class b extends dd {
    private int c;
    private a d;

    public b() {

    }

    public abstract View a(ViewGroup arg1);

    public abstract void a(View arg1, int arg2, Object arg3);

    public void a(Object arg11) {
        Object v1_1;
        a v0;
        View v1;
        View v2 = null;
        if (this.d == null) {
            v1 = ((Activity) this.b().b).findViewById(com.ss.android.article.browser.R.id.list);
            if (v1 == null) {
                v0 = ((a) null);
            } else {
                v0 = (com.ss.android.k.d.a) v1.getTag(com.ss.android.article.browser.R.id.bn);
            }

            this.d = v0;
            if (this.d != null) {
            } else {
                this.d = new a();
                v0 = this.d;
                if (v1 == null) {
                } else {
                    v1.setTag(com.ss.android.article.browser.R.id.c2, v0);
                }
            }
        }

        View v0_2 = this.a();
        int v6 = this.b(arg11);
        int v5;
        for (v5 = 0; v5 < v6; ++v5) {
            if (v5 < ((ViewGroup) v0_2).getChildCount()) {
                v1_1 = ((ViewGroup) v0_2).getChildAt(v5);
            } else {
                if (this.c == 0) {
                    View v4 = this.a(((ViewGroup) v0_2));
                    v1_1 = v4.getTag(com.ss.android.article.browser.R.id.tag_layout_id);
                    int v1_2 = v1_1 == null ? 0 : ((Integer) v1_1).intValue();
                    this.c = v1_2;
                    v1_1 = v4;
                } else {
                    a v7 = this.d;
                    int v8 = this.c;
                    v1_1 = v7.a.get(v8);
                    if (v1_1 != null) {
                        Object v4_1 = ((Queue) v1_1).poll();
                        if (((Queue) v1_1).isEmpty()) {
                            v7.a.remove(v8);
                        }

                        Log.d("RecycleBin", "[Hit] recycleKey=" + v8);
                        v1_1 = v4_1;
                    } else {
                        v1_1 = v2;
                    }

                    if (v1_1 != null) {
                    } else {
                        v1_1 = this.a(((ViewGroup) v0_2));
                    }
                }
                ((ViewGroup) v0_2).addView(((View) v1_1));
            }

            this.a(((View) v1_1), v5, arg11);
        }

        while (v5 < ((ViewGroup) v0_2).getChildCount()) {
            v2 = ((ViewGroup) v0_2).getChildAt(v5);
            ((ViewGroup) v0_2).removeView(v2);
            if (this.c == 0) {
                continue;
            }

            a v3 = this.d;
            int v4_2 = this.c;
            v1_1 = v3.a.get(v4_2);
            if (v1_1 == null) {
                LinkedList v1_3 = new LinkedList();
                v3.a.put(v4_2, v1_3);
            }

            ((Queue) v1_1).add(v2);
        }
    }

    public abstract int b(Object arg1);
}

